Fix transitive doctests panic=abort
authorAlex Crichton <alex@alexcrichton.com>
Fri, 19 Aug 2016 20:25:13 +0000 (13:25 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 19 Aug 2016 20:29:11 +0000 (13:29 -0700)
Ensure that when we compile doctested libraries or examples we use the same
panic mode as the rest of the tests, namely ignoring panic=abort b/c libtest
isn't compiled with panic=abort.

Closes #3017

src/cargo/ops/cargo_compile.rs
tests/test.rs

index 3ea700f49afd646d839231fafb0df9c264d95d51..da66aca91d3be1a8a60beb16c0e5fea14a97b689 100644 (file)
@@ -308,17 +308,22 @@ fn generate_targets<'a>(pkg: &'a Package,
                     }).collect::<Vec<_>>())
                 }
                 CompileMode::Test => {
+                    let deps = if release {
+                        &profiles.bench_deps
+                    } else {
+                        &profiles.test_deps
+                    };
                     let mut base = pkg.targets().iter().filter(|t| {
                         t.tested()
                     }).map(|t| {
-                        (t, if t.is_example() {build} else {profile})
+                        (t, if t.is_example() {deps} else {profile})
                     }).collect::<Vec<_>>();
 
                     // Always compile the library if we're testing everything as
                     // it'll be needed for doctests
                     if let Some(t) = pkg.targets().iter().find(|t| t.is_lib()) {
                         if t.doctested() {
-                            base.push((t, build));
+                            base.push((t, deps));
                         }
                     }
                     Ok(base)
index d48db7bcc16d0cd5265db9d0741639dea8a0b979..2e5d8aa57beddf5de2757ec0d30acb0df60b0167 100644 (file)
@@ -2232,3 +2232,33 @@ fn cfg_test_even_with_no_harness() {
 [RUNNING] `[..]`
 "));
 }
+
+#[test]
+fn panic_abort_multiple() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies]
+            a = { path = "a" }
+
+            [profile.release]
+            panic = 'abort'
+        "#)
+        .file("src/lib.rs", "extern crate a;")
+        .file("a/Cargo.toml", r#"
+            [package]
+            name = "a"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("a/src/lib.rs", "");
+    assert_that(p.cargo_process("test")
+                 .arg("--release").arg("-v")
+                 .arg("-p").arg("foo")
+                 .arg("-p").arg("a"),
+                execs().with_status(0));
+}